package com.ruoyi.web.rabbitmq;

import com.ruoyi.web.websocket.WebSocketServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * rabbitmq发送消息工具类
 *
 * @author chenhf
 * @create 2017-10-26 上午11:10
 **/
@Component
@RabbitListener(queues = RabbitConfig.ORDERQUEUE)
public class RabbitMqReceive {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @RabbitHandler
    public void process(String content) {
        System.out.println("新订单接收到的消息:" + content);
        logger.info("接收处理队列A当中的消息： " + content);
        WebSocketServer webSocketServer = new WebSocketServer();
        try {
            webSocketServer.sendInfo(content,null);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
